﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class FG : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DropBind();
        }
    }

   
    protected void Button1_Click(object sender, EventArgs e)
    {
        ID = Session["username"].ToString();
        string sql;
        sql = "update  allusers set 邮箱='" + this.TextBox2.Text + "',手机='" + this.TextBox3.Text + "',邮编='" + this.TextBox4.Text + "' where username='" + ID + "'";

        int result;
        result = new Class1().hsgexucute(sql);
        if (result == 1)
        {
            Response.Write("<script>javascript:alert('操作成功');</script>");
        }
        else
        {
            Response.Write("<script>javascript:alert('系统错误，您没有设置好数据库的连接！');</script>");
        }
    }


    private void DropBind()
    {
        this.TextBox1.Text = Session["username"].ToString();
        string sql = "select * from allusers ";
        DataSet ds = new DataSet();
        ds = new Class1().hsggetdata(sql);

        if (ds != null)
        {
            if (ds.Tables[0].Rows.Count > 0)
            {
                this.TextBox2.Text = ds.Tables[0].Rows[0]["邮箱"].ToString().Trim();
                TextBox3.Text = ds.Tables[0].Rows[0]["手机"].ToString().Trim();
                this.TextBox4.Text = ds.Tables[0].Rows[0]["邮编"].ToString().Trim();
            }
        }

    }
   
   
}
